Skip to content

refactor(kms-auth)!: slim DstackKms bytecode - #1569

Merged
kvinwang merged 1 commit into
nextfrom
refactor/kms-contract-size
Nov 12, 2026
Merged

kvinwang merged 1 commit into
nextfrom
refactor/kms-contract-size

Conversation

@kvinwang

@kvinwang kvinwang commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

DstackKms was 24,041 bytes after #1567, against the 24,576-byte EIP-170 limit. This takes it to 22,621 without splitting the contract:

  • Custom errors instead of revert strings in DstackKms setters. Authorization rejection reasons (forwarded by the auth backends) are unchanged.
  • Drop the six single-epoch DstackKms setters (add/remove{KmsAggregatedMr,KmsDevice,OsImageHash}AtEpoch); use *AtEpochs(e, e, v). Manage.s.sol already used the range forms; the two tutorials' cast commands are updated.
  • _emitPolicy takes the compile-time policy hash instead of hashing a string at run time; event values are unchanged.

Breaking: the revert strings of registerApp, setAppImplementation and deployAndRegisterApp shipped in v0.6.0 and become custom errors (listed in the CHANGELOG); the rest is unreleased API.

Tests: forge clean && forge test --ffi (114 passed); Halmos (FOUNDRY_DYNAMIC_TEST_LINKING=false) DstackKmsSymbolicTest 11/11, DstackKmsEpochSymbolicTest 13/13.

@kvinwang
kvinwang force-pushed the refactor/kms-contract-size branch from 456c0cd to aae113a Compare November 12, 2026 12:59
DstackKms was 24,041 bytes against the 24,576-byte EIP-170 limit, leaving
little room for new features. This takes it to 22,621 without splitting the
contract:

- Revert with custom errors instead of revert strings. Authorization
  rejection reasons, which the auth backends forward, are unchanged.
- Drop the single-epoch addKmsAggregatedMrAtEpoch, addKmsDeviceAtEpoch,
  addOsImageHashAtEpoch and their remove counterparts; *AtEpochs(e, e, v)
  writes one root epoch. Manage.s.sol already used the range forms.
- Pass _emitPolicy the policy hash, folded at compile time, instead of
  hashing a string at run time. Event values are unchanged.

BREAKING CHANGE: DstackKms setters revert with custom errors. The revert
strings of registerApp, setAppImplementation and deployAndRegisterApp
shipped in v0.6.0; the others and the single-epoch setters are unreleased.

Signed-off-by: Kevin Wang <wy721@qq.com>
@kvinwang
kvinwang force-pushed the refactor/kms-contract-size branch from aae113a to 49b7c05 Compare November 12, 2026 13:11
@kvinwang
kvinwang merged commit daa37a9 into next Nov 12, 2026
24 checks passed
@kvinwang
kvinwang deleted the refactor/kms-contract-size branch November 12, 2026 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant